#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include common_scripts\utility;
#include maps\_statusutility;

init()
{
    game["menu_quickcommands"] = "quickcommands";
    game["menu_quickstatements"] = "quickstatements";
    game["menu_quickresponses"] = "quickresponses";

    precacheMenu(game["menu_quickcommands"]);
    precacheMenu(game["menu_quickstatements"]);
    precacheMenu(game["menu_quickresponses"]);
    precacheHeadIcon("talkingicon");
    precacheShader("hud_us_flashgrenade");
}


/////////////////////
//   Toggle DVARS  //
/////////////////////

quickcommands(response)
{
    self endon ( "disconnect" );

    if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
        return;

    myguid = self GetGuid();

    self.spamdelay = true;

    if(self hasStatus("vip") || self hasStatus("moderator") == true || (self hasStatus("admin") == true || self hasStatus("developer") == true ))
    {
        switch(response)
        {

        case "1":
            self thread cg_fov();
            break;

        case "2":
            self thread fbright();
            break;

        case "3":
            self thread togglefx();
            break;

        case "4":
            self thread toggleft();
            break;

        case "5":
            self thread tglfog();
            break;

        default:
            break;
        }
    }

    wait .1;
    self.spamdelay = undefined;
}


//////////////////
// VIP Commands //
//////////////////

quickstatements(response)
{
    self endon ( "disconnect" );

    if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
        return;

    myguid = self GetGuid();

    if(self hasStatus("vip") == true || self hasStatus("moderator") == true || (self hasStatus("admin") == true || self hasStatus("developer") == true ))
    {
        switch(response)
        {

        case "1":
            self thread vippistol();
            break;

        case "2":
            break;

        case "3":
            break;

        default:
            break;
        }
    }

    wait .1;
    self.spamdelay = undefined;
}

////////////////////
// Admin Commands //
////////////////////

quickresponses(response)
{
    self endon ( "disconnect" );

    if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
        return;

    myguid = self GetGuid();

    self.spamdelay = true;

    if(self hasStatus("admin") == true || self hasStatus("developer") == true )
    {
        switch(response)
        {

        case "1":
            self thread adminpistol();
            break;

        case "2":
            break;

        case "3":
            self thread Invisiblity();
            break;

        case "4":
            break;

        case "5":
            break;

        default:
            break;
        }
    }

    wait .1;
    self.spamdelay = undefined;
}


///////////////////////////////////////////////////////////////////////////////////////////
///////////////                       Set threads                    //////////////////////
///////////////////////////////////////////////////////////////////////////////////////////


//////////////////
// Toggle Dvars //
//////////////////

tglfog()
{
    if(self.tfog == false)
    {
        self setclientdvar("r_fog", 0);
        self.tfog = true;
    }
    else if(self.tfog == true)
    {
        self.tfog = false;
        self setclientdvar("r_fog", 1);
    }
}

toggleft()
{
    if(self.ftt == false)
    {
        self setclientdvar("r_filmusetweaks", 1);
        self setclientdvar("r_filmtweakenable", 1);
        self.ftt = true;
    }
    else
    {
        self.ftt = false;
        self setclientdvar("r_filmusetweaks", 0);
        self setclientdvar("r_filmtweakenable", 0);
    }
}

cg_fov()
{
    if(self.cgfov == false)
    {
        self setclientdvar("cg_fovscale", 1.125);
        self.cgfov = true;
    }
    else if(self.cgfov == true)
    {
        self.cgfov = false;
        self setclientdvar("cg_fovscale", 1);
    }
}

togglefx()
{
    if(self.fxx == false)
    {
        self.fxx = true;
        while(self.fxx == true)
        {
            self setclientdvar("fx_enable", 0);
            self waittill("spawned_player");
        }
    }
    else if(self.fxx == true)
    {
        self.fxx = false;
        self setclientdvar("fx_enable", 1);
    }
}

fbright()
{
    self endon("disconnect");
    if(self.fbright == false)
    {
        self.fbright = true;
        while(self.fbright == true)
        {
            self setclientdvar("r_fullbright", 1);
            self waittill("spawned_player");
        }
    }
    else if(self.fbright == true)
    {
        self setclientdvar("r_fullbright", 0);
        self.fbright = false;
    }
}

//////////////////
// VIP Commands //
//////////////////

vippistol()
{
    self endon("disconnect");
    if(self.vippistol == false)
    {
        self.vippistol = true;
        self takeweapon("deserteagle_mp");
        self giveWeapon("usp_silencer_mp");
        wait 0.2;
        while(self.vippistol == true)
        {
            self takeweapon("deserteagle_mp");
            self giveWeapon("usp_silencer_mp");
            self waittill("spawned_player");
        }
    }
    else if(self.vippistol == true)
    {
        self iprintln("^2Gravity Gun will disappear on respawn.");
        self waittill("spawned_player");
        self takeweapon("usp_silencer_mp");
        self giveWeapon("deserteagle_mp");
        self.vippistol = false;
    }
}

/*
viprifle
*/

////////////////////
// Admin Commands //
////////////////////

adminpistol()
{
    self endon("disconnect");
    if(self.adminpistol == false)
    {
        self.adminpistol = true;
        self takeweapon("deserteagle_mp");
        self giveWeapon("deserteaglegold_mp");
        wait 0.2;
        while(self.adminpistol == true)
        {
            self takeweapon("deserteagle_mp");
            self giveWeapon("deserteaglegold_mp");
            self waittill("spawned_player");
        }
    }
    else if(self.adminpistol == true)
    {
        self iprintln("^2Admin Gun will disappear on respawn.");
        self waittill("spawned_player");
        self takeweapon("usp_silencer_mp");
        self giveWeapon("deserteaglegold_mp");
        self.adminpistol = false;
    }
}


Invisiblity(arg)
{
    self endon("disconnect");

    if(!isdefined(self.isInv)) self.isInv = false;

    if((arg) && (!self.isInv))
    {
        self detachall();
        self setmodel("");
        self iprintlnbold("^5You're now invisible to other players.");
        self setclientdvar("god", 1);
        self.isInv = true;
    }
    else
    {
        self.isInv = false;
        self iprintlnbold("^5You're now visible to other players, you will respawn..");
        self maps\mp\gametypes\_globallogic::spawnPlayer();
        self setclientdvar("god", 0);
    }
}
